import table from '@/components/dt/table/render.js'
import Opt from '@/components/dt/info/Opt.js'

let _this = null

class Column extends Opt {
  constructor(vm) {
    super()
    _this = vm
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    console.log(_this.curState, 'curState')
    this.all = []
    let publicArr = [{
        title: '展示姓名',
        field: 'userName',
        minWidth: 120
      },
      // {
      //   title: '工号',
      //   field: 'workNo',
      //   minWidth: 120
      // },
      {
        title: '展示手机号',
        field: 'phone',
        minWidth: 120
      },
      {
        title: '展示职位',
        field: 'positionName',
        minWidth: 120
      },
      {
        title: '展示邮箱',
        field: 'email',
        minWidth: 150
      },
      // {
      //   title: '微信',
      //   field: 'wechat',
      //   minWidth: 150
      // },
      {
        title: '展示公司名',
        field: 'companyName',
        minWidth: 200
      },
      {
        title: '展示地址',
        field: 'address',
        minWidth: 220
      },
      {
        title: '提交人',
        field: 'userNameWorkNo',
        minWidth: 120
      },
      {
        title: '提交人手机号',
        field: 'submitPhone',
        minWidth: 140
      },
      {
        title: '提交时间',
        field: 'submitTime',
        minWidth: 180
      }
    ]

    let waitAuditArr = [{
      title: '操作',
      fixed: 'right',
      minWidth: 150,
      align: 'center',
      slots: {
        default: (params, h) => {
          let btns = []
          btns.push({
            title: '审核',
            event: 'auditFun',
            data: params.row
          })
          return table.cell.btns(_this, h, btns)
        }
      }
    }]
    let passAuditArr = [
    {
      title: '审批人',
      field: 'auditName',
      minWidth: 120
    },
    {
      title: '审批时间',
      field: 'auditTime',
      minWidth: 180
    },
    {
      title: '操作',
      fixed: 'right',
      minWidth: 150,
      align: 'center',
      slots: {
        default: (params, h) => {
          let btns = []
          btns.push({
            title: '流程信息',
            event: 'processFun',
            data: params.row
          })
          return table.cell.btns(_this, h, btns)
        }
      }
    }]
    let rejectAuditArr = [
    {
      title: '审批人',
      field: 'auditName',
      minWidth: 120
    },
    {
      title: '审批时间',
      field: 'auditTime',
      minWidth: 180
    },
    {
      title: '驳回原因',
      field: 'auditReason',
      minWidth: 220
    },
    {
      title: '操作',
      fixed: 'right',
      minWidth: 150,
      align: 'center',
      slots: {
        default: (params, h) => {
          let btns = []
          btns.push({
            title: '流程信息',
            event: 'processFun',
            data: params.row
          })
          return table.cell.btns(_this, h, btns)
        }
      }
    }]
    if (_this.curState == '0') {
      this.all.push(...publicArr, ...waitAuditArr)
    } else if (_this.curState == '1') {
      this.all.push(...publicArr, ...passAuditArr)
    } else if (_this.curState == '2') {
      this.all.push(...publicArr, ...rejectAuditArr)
    }
  }

}

export default Column